# coding: utf-8
import sqlalchemy
from fontTools.feaLib.ast import Expression
from sqlalchemy import CHAR, Column, DECIMAL, Date, DateTime, Enum, Float, Index, String, Table, Text, Time, text
from sqlalchemy.dialects.mysql import BIGINT, DECIMAL, INTEGER, LONGTEXT, MEDIUMINT, MEDIUMTEXT, SET, SMALLINT, TINYINT, VARCHAR, YEAR
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata


class FaAdmin(Base):
    __tablename__ = 'fa_admin'
    __table_args__ = {'comment': '管理员表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    username = Column(String(20), unique=True, server_default=text("''"), comment='用户名')
    nickname = Column(String(50), server_default=text("''"), comment='昵称')
    password = Column(String(32), server_default=text("''"), comment='密码')
    salt = Column(String(30), server_default=text("''"), comment='密码盐')
    avatar = Column(String(255), server_default=text("''"), comment='头像')
    email = Column(String(100), server_default=text("''"), comment='电子邮箱')
    mobile = Column(String(11), server_default=text("''"), comment='手机号码')
    loginfailure = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='失败次数')
    logintime = Column(BIGINT(16), comment='登录时间')
    loginip = Column(String(50), comment='登录IP')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    token = Column(String(59), server_default=text("''"), comment='Session标识')
    status = Column(String(30), nullable=False, server_default=text("'normal'"), comment='状态')


class FaAdminLog(Base):
    __tablename__ = 'fa_admin_log'
    __table_args__ = {'comment': '管理员日志表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    admin_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='管理员ID')
    username = Column(String(30), index=True, server_default=text("''"), comment='管理员名字')
    url = Column(String(1500), server_default=text("''"), comment='操作页面')
    title = Column(String(100), server_default=text("''"), comment='日志标题')
    content = Column(LONGTEXT, nullable=False, comment='内容')
    ip = Column(String(50), server_default=text("''"), comment='IP')
    useragent = Column(String(255), server_default=text("''"), comment='User-Agent')
    createtime = Column(BIGINT(16), comment='操作时间')


class FaArea(Base):
    __tablename__ = 'fa_area'
    __table_args__ = {'comment': '地区表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    pid = Column(INTEGER(10), index=True, comment='父id')
    shortname = Column(String(100), comment='简称')
    name = Column(String(100), comment='名称')
    mergename = Column(String(255), comment='全称')
    level = Column(TINYINT(4), comment='层级:1=省,2=市,3=区/县')
    pinyin = Column(String(100), comment='拼音')
    code = Column(String(100), comment='长途区号')
    zip = Column(String(100), comment='邮编')
    first = Column(String(50), comment='首字母')
    lng = Column(String(100), comment='经度')
    lat = Column(String(100), comment='纬度')


class FaAttachment(Base):
    __tablename__ = 'fa_attachment'
    __table_args__ = {'comment': '附件表'}

    id = Column(INTEGER(20), primary_key=True, comment='ID')
    category = Column(String(50), server_default=text("''"), comment='类别')
    admin_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='管理员ID')
    user_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='会员ID')
    url = Column(String(255), server_default=text("''"), comment='物理路径')
    imagewidth = Column(String(30), server_default=text("''"), comment='宽度')
    imageheight = Column(String(30), server_default=text("''"), comment='高度')
    imagetype = Column(String(30), server_default=text("''"), comment='图片类型')
    imageframes = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='图片帧数')
    filename = Column(String(100), server_default=text("''"), comment='文件名称')
    filesize = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='文件大小')
    mimetype = Column(String(100), server_default=text("''"), comment='mime类型')
    extparam = Column(String(255), server_default=text("''"), comment='透传数据')
    createtime = Column(BIGINT(16), comment='创建日期')
    updatetime = Column(BIGINT(16), comment='更新时间')
    uploadtime = Column(BIGINT(16), comment='上传时间')
    storage = Column(String(100), nullable=False, server_default=text("'local'"), comment='存储位置')
    sha1 = Column(String(40), server_default=text("''"), comment='文件 sha1编码')


class FaAuthGroup(Base):
    __tablename__ = 'fa_auth_group'
    __table_args__ = {'comment': '分组表'}

    id = Column(INTEGER(10), primary_key=True)
    pid = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='父组别')
    name = Column(String(100), server_default=text("''"), comment='组名')
    rules = Column(Text, nullable=False, comment='规则ID')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(String(30), server_default=text("''"), comment='状态')


t_fa_auth_group_access = Table(
    'fa_auth_group_access', metadata,
    Column('uid', INTEGER(10), nullable=False, index=True, comment='会员ID'),
    Column('group_id', INTEGER(10), nullable=False, index=True, comment='级别ID'),
    Index('uid_group_id', 'uid', 'group_id', unique=True),
    comment='权限分组表'
)


class FaAuthRule(Base):
    __tablename__ = 'fa_auth_rule'
    __table_args__ = {'comment': '节点表'}

    id = Column(INTEGER(10), primary_key=True)
    type = Column(Enum('menu', 'file'), nullable=False, server_default=text("'file'"), comment='menu为菜单,file为权限节点')
    pid = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='父ID')
    name = Column(String(100), unique=True, server_default=text("''"), comment='规则名称')
    title = Column(String(50), server_default=text("''"), comment='规则名称')
    icon = Column(String(50), server_default=text("''"), comment='图标')
    url = Column(String(255), server_default=text("''"), comment='规则URL')
    condition = Column(String(255), server_default=text("''"), comment='条件')
    remark = Column(String(255), server_default=text("''"), comment='备注')
    ismenu = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='是否为菜单')
    menutype = Column(Enum('addtabs', 'blank', 'dialog', 'ajax'), comment='菜单类型')
    extend = Column(String(255), server_default=text("''"), comment='扩展属性')
    py = Column(String(30), server_default=text("''"), comment='拼音首字母')
    pinyin = Column(String(100), server_default=text("''"), comment='拼音')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    weigh = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='权重')
    status = Column(String(30), server_default=text("''"), comment='状态')


class FaCategory(Base):
    __tablename__ = 'fa_category'
    __table_args__ = (
        Index('weigh', 'weigh', 'id'),
        {'comment': '分类表'}
    )

    id = Column(INTEGER(10), primary_key=True)
    pid = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='父ID')
    type = Column(String(30), server_default=text("''"), comment='栏目类型')
    name = Column(String(30), server_default=text("''"))
    nickname = Column(String(50), server_default=text("''"))
    flag = Column(SET('hot', 'index', 'recommend'), server_default=text("''"))
    image = Column(String(100), server_default=text("''"), comment='图片')
    keywords = Column(String(255), server_default=text("''"), comment='关键字')
    description = Column(String(255), server_default=text("''"), comment='描述')
    diyname = Column(String(30), server_default=text("''"), comment='自定义名称')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    status = Column(String(30), server_default=text("''"), comment='状态')


class FaCmsAddondownload(Base):
    __tablename__ = 'fa_cms_addondownload'
    __table_args__ = {'comment': '下载'}

    id = Column(INTEGER(10), primary_key=True)
    content = Column(LONGTEXT, nullable=False)
    os = Column(SET('windows', 'linux', 'mac', 'ubuntu'), server_default=text("''"), comment='操作系统')
    version = Column(String(255), server_default=text("''"), comment='最新版本')
    filesize = Column(String(255), server_default=text("''"), comment='文件大小')
    language = Column(SET('zh-cn', 'en'), server_default=text("''"), comment='语言')
    downloadurl = Column(String(1500), server_default=text("''"), comment='下载地址')
    screenshots = Column(String(1500), server_default=text("''"), comment='预览截图')
    downloads = Column(String(10), server_default=text("'0'"), comment='下载次数')


class FaCmsAddonnew(Base):
    __tablename__ = 'fa_cms_addonnews'
    __table_args__ = {'comment': '新闻'}

    id = Column(INTEGER(10), primary_key=True)
    content = Column(LONGTEXT, nullable=False)
    author = Column(String(50), server_default=text("''"), comment='作者')


class FaCmsAddonproduct(Base):
    __tablename__ = 'fa_cms_addonproduct'
    __table_args__ = {'comment': '产品表'}

    id = Column(INTEGER(10), primary_key=True)
    content = Column(LONGTEXT, nullable=False)
    productdata = Column(String(1500), server_default=text("''"), comment='产品列表')


class FaCmsArchive(Base):
    __tablename__ = 'fa_cms_archives'
    __table_args__ = (
        Index('weigh', 'weigh', 'publishtime'),
        {'comment': '内容表'}
    )

    id = Column(INTEGER(10), primary_key=True)
    user_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='会员ID')
    channel_id = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='栏目ID')
    channel_ids = Column(String(100), index=True, server_default=text("''"), comment='副栏目ID集合')
    model_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='模型ID')
    special_ids = Column(String(100), server_default=text("''"), comment='专题ID集合')
    admin_id = Column(INTEGER(10), server_default=text("'0'"), comment='管理员ID')
    title = Column(String(255), server_default=text("''"), comment='文章标题')
    flag = Column(String(100), server_default=text("''"), comment='标志')
    style = Column(String(100), server_default=text("''"), comment='样式')
    image = Column(String(255), server_default=text("''"), comment='缩略图')
    images = Column(String(1500), server_default=text("''"), comment='组图')
    seotitle = Column(String(255), server_default=text("''"), comment='SEO标题')
    keywords = Column(String(255), server_default=text("''"), comment='关键字')
    description = Column(String(255), server_default=text("''"), comment='描述')
    tags = Column(String(255), server_default=text("''"), comment='TAG')
    price = Column(DECIMAL(10, 2), server_default=text("'0.00'"), comment='价格')
    outlink = Column(String(255), server_default=text("''"), comment='外部链接')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    views = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='浏览次数')
    comments = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='评论次数')
    likes = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='点赞数')
    dislikes = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='点踩数')
    diyname = Column(String(100), index=True, server_default=text("''"), comment='自定义URL')
    isguest = Column(TINYINT(1), server_default=text("'1'"), comment='是否访客访问')
    iscomment = Column(TINYINT(1), server_default=text("'1'"), comment='是否允许评论')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    publishtime = Column(BIGINT(16), comment='发布时间')
    deletetime = Column(BIGINT(16), comment='删除时间')
    memo = Column(String(100), server_default=text("''"), comment='备注')
    status = Column(Enum('normal', 'hidden', 'rejected', 'pulloff'), nullable=False, server_default=text("'normal'"), comment='状态')


class FaCmsAutolink(Base):
    __tablename__ = 'fa_cms_autolink'
    __table_args__ = {'comment': '自动链接表'}

    id = Column(INTEGER(10), primary_key=True)
    title = Column(String(100), comment='标题')
    url = Column(String(255), server_default=text("''"), comment='链接')
    target = Column(Enum('self', 'blank'), server_default=text("'blank'"), comment='打开方式')
    weigh = Column(INTEGER(10), server_default=text("'0'"), comment='排序')
    views = Column(INTEGER(10), server_default=text("'0'"), comment='点击次数')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('normal', 'hidden'), server_default=text("'normal'"), comment='状态')


class FaCmsBlock(Base):
    __tablename__ = 'fa_cms_block'
    __table_args__ = {'comment': '区块表'}

    id = Column(SMALLINT(8), primary_key=True)
    type = Column(String(30), server_default=text("''"), comment='类型')
    name = Column(String(50), index=True, server_default=text("''"), comment='名称')
    title = Column(String(100), server_default=text("''"), comment='标题')
    image = Column(String(255), server_default=text("''"), comment='图片')
    url = Column(String(255), server_default=text("''"), comment='链接')
    content = Column(MEDIUMTEXT, comment='内容')
    parsetpl = Column(TINYINT(1), server_default=text("'0'"), comment='解析模板标签')
    weigh = Column(INTEGER(10), server_default=text("'0'"), comment='权重')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    begintime = Column(BIGINT(16), comment='开始时间')
    endtime = Column(BIGINT(16), comment='结束时间')
    status = Column(Enum('normal', 'hidden'), nullable=False, server_default=text("'normal'"), comment='状态')


class FaCmsChannel(Base):
    __tablename__ = 'fa_cms_channel'
    __table_args__ = (
        Index('weigh', 'weigh', 'id'),
        {'comment': '栏目表'}
    )

    id = Column(INTEGER(10), primary_key=True)
    type = Column(Enum('channel', 'page', 'link', 'list'), nullable=False, index=True, comment='类型')
    model_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='模型ID')
    parent_id = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='父ID')
    name = Column(String(30), server_default=text("''"), comment='名称')
    image = Column(String(255), server_default=text("''"), comment='图片')
    flag = Column(String(100), server_default=text("''"), comment='标志')
    seotitle = Column(String(255), server_default=text("''"), comment='SEO标题')
    keywords = Column(String(255), server_default=text("''"), comment='关键字')
    description = Column(String(255), server_default=text("''"), comment='描述')
    diyname = Column(String(100), unique=True, server_default=text("''"), comment='自定义名称')
    outlink = Column(String(255), server_default=text("''"), comment='外部链接')
    linktype = Column(String(100), server_default=text("''"), comment='链接类型')
    linkid = Column(INTEGER(10), server_default=text("'0'"), comment='链接ID')
    items = Column(MEDIUMINT(8), nullable=False, server_default=text("'0'"), comment='文章数量')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    channeltpl = Column(String(100), server_default=text("''"), comment='栏目页模板')
    listtpl = Column(String(100), server_default=text("''"), comment='列表页模板')
    showtpl = Column(String(100), server_default=text("''"), comment='详情页模板')
    pagesize = Column(SMALLINT(5), nullable=False, server_default=text("'0'"), comment='分页大小')
    vip = Column(TINYINT(1), server_default=text("'0'"), comment='VIP')
    listtype = Column(TINYINT(1), server_default=text("'0'"), comment='列表数据类型')
    iscontribute = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='是否可投稿')
    isnav = Column(TINYINT(1), nullable=False, server_default=text("'1'"), comment='是否导航显示')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('normal', 'hidden'), nullable=False, server_default=text("'normal'"), comment='状态')


class FaCmsChannelAdmin(Base):
    __tablename__ = 'fa_cms_channel_admin'
    __table_args__ = (
        Index('admin_id', 'admin_id', 'channel_id', unique=True),
        {'comment': '栏目权限表'}
    )

    id = Column(INTEGER(10), primary_key=True)
    admin_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='管理员ID')
    channel_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='栏目ID')


class FaCmsCollection(Base):
    __tablename__ = 'fa_cms_collection'
    __table_args__ = (
        Index('aid', 'type', 'aid', 'user_id', unique=True),
        {'comment': '收藏表'}
    )

    id = Column(INTEGER(10), primary_key=True)
    type = Column(Enum('archives', 'special', 'page', 'diyform'), comment='类型')
    aid = Column(INTEGER(10), server_default=text("'0'"), comment='关联ID')
    user_id = Column(INTEGER(10), comment='会员ID')
    title = Column(String(255), comment='收藏标题')
    image = Column(String(255), comment='图片')
    url = Column(String(255), comment='URL')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')


class FaCmsComment(Base):
    __tablename__ = 'fa_cms_comment'
    __table_args__ = (
        Index('post_id', 'aid', 'pid'),
        {'comment': '评论表'}
    )

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    user_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='会员ID')
    type = Column(Enum('archives', 'page', 'special'), nullable=False, server_default=text("'archives'"), comment='类型')
    aid = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='关联ID')
    pid = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='父ID')
    content = Column(LONGTEXT, comment='内容')
    comments = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='评论数')
    ip = Column(String(50), server_default=text("''"), comment='IP')
    useragent = Column(String(255), server_default=text("''"), comment='User Agent')
    subscribe = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='订阅')
    createtime = Column(BIGINT(16), nullable=False, server_default=text("'0'"), comment='创建时间')
    updatetime = Column(BIGINT(16), nullable=False, server_default=text("'0'"), comment='更新时间')
    deletetime = Column(BIGINT(16), comment='删除时间')
    status = Column(Enum('normal', 'hidden'), nullable=False, server_default=text("'normal'"), comment='状态')


class FaCmsDiyform(Base):
    __tablename__ = 'fa_cms_diyform'
    __table_args__ = {'comment': '自定义表单表'}

    id = Column(SMALLINT(5), primary_key=True)
    admin_id = Column(INTEGER(10), server_default=text("'0'"), comment='管理员ID')
    name = Column(CHAR(30), server_default=text("''"), comment='表单名称')
    title = Column(String(100), comment='标题')
    seotitle = Column(String(255), server_default=text("''"), comment='SEO标题')
    posttitle = Column(String(255), server_default=text("''"), comment='发布标题')
    keywords = Column(String(100), comment='关键字')
    description = Column(String(255), comment='描述')
    table = Column(String(50), server_default=text("''"), comment='表名')
    fields = Column(Text, comment='字段列表')
    isguest = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='是否访客访问')
    needlogin = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='是否需要登录发布')
    isedit = Column(TINYINT(1), server_default=text("'0'"), comment='是否允许编辑')
    iscaptcha = Column(TINYINT(1), server_default=text("'0'"), comment='是否启用验证码')
    successtips = Column(String(255), comment='成功提示文字')
    redirecturl = Column(String(255), comment='成功后跳转链接')
    posttpl = Column(String(50), server_default=text("''"), comment='表单页模板')
    listtpl = Column(String(50), server_default=text("''"), comment='列表页模板')
    showtpl = Column(String(50), server_default=text("''"), comment='详情页模板')
    diyname = Column(String(100), index=True, comment='自定义名称')
    usermode = Column(Enum('all', 'user'), server_default=text("'all'"), comment='用户筛选模式')
    statusmode = Column(Enum('all', 'normal', 'hidden'), server_default=text("'all'"), comment='状态筛选模式')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    setting = Column(String(1500), comment='表单配置')
    status = Column(Enum('normal', 'hidden'), server_default=text("'hidden'"), comment='状态')


class FaCmsField(Base):
    __tablename__ = 'fa_cms_fields'
    __table_args__ = {'comment': '模型字段表'}

    id = Column(SMALLINT(5), primary_key=True)
    source = Column(String(30), index=True, server_default=text("''"), comment='来源')
    source_id = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='来源ID')
    name = Column(CHAR(30), server_default=text("''"), comment='名称')
    type = Column(String(30), server_default=text("''"), comment='类型')
    title = Column(String(30), server_default=text("''"), comment='标题')
    content = Column(Text, comment='内容')
    filterlist = Column(Text, comment='筛选列表')
    defaultvalue = Column(String(100), server_default=text("''"), comment='默认值')
    rule = Column(String(100), server_default=text("''"), comment='验证规则')
    msg = Column(String(100), server_default=text("''"), comment='错误消息')
    ok = Column(String(100), server_default=text("''"), comment='成功消息')
    tip = Column(String(100), server_default=text("''"), comment='提示消息')
    decimals = Column(TINYINT(1), comment='小数点')
    length = Column(MEDIUMINT(8), comment='长度')
    minimum = Column(SMALLINT(6), comment='最小数量')
    maximum = Column(SMALLINT(6), nullable=False, server_default=text("'0'"), comment='最大数量')
    extend = Column(String(255), server_default=text("''"), comment='扩展信息')
    setting = Column(String(1500), server_default=text("''"), comment='配置信息')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='排序')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    isorder = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='是否可排序')
    iscontribute = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='是否可投稿')
    isfilter = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='筛选')
    status = Column(Enum('normal', 'hidden'), nullable=False, comment='状态')


class FaCmsFriendlink(Base):
    __tablename__ = 'fa_cms_friendlink'
    __table_args__ = {'comment': '友情链接'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    user_id = Column(INTEGER(10), index=True, comment='会员ID')
    title = Column(String(255), server_default=text("''"), comment='站点名称')
    image = Column(String(1500), server_default=text("''"), comment='站点Logo')
    website = Column(String(100), server_default=text("''"), comment='站点链接')
    createtime = Column(BIGINT(16), index=True, comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    memo = Column(String(1500), server_default=text("''"), comment='备注')
    status = Column(Enum('normal', 'hidden', 'rejected'), server_default=text("'hidden'"), comment='状态')
    intro = Column(String(255), server_default=text("''"), comment='站点介绍')


class FaCmsMessage(Base):
    __tablename__ = 'fa_cms_message'
    __table_args__ = {'comment': '站内留言'}

    id = Column(INTEGER(10), primary_key=True)
    user_id = Column(INTEGER(10), index=True, comment='会员ID')
    name = Column(String(50), server_default=text("''"), comment='姓名')
    telephone = Column(String(100), server_default=text("''"), comment='电话')
    qq = Column(String(30), server_default=text("''"), comment='QQ')
    content = Column(LONGTEXT, comment='内容')
    os = Column(Enum('windows', 'mac'), server_default=text("'windows'"), comment='操作系统')
    language = Column(SET('zh-cn', 'en'), server_default=text("''"), comment='语言')
    address = Column(String(255), server_default=text("''"), comment='地区')
    category = Column(String(255), server_default=text("''"), comment='分类')
    memo = Column(String(255), server_default=text("''"), comment='备注')
    image = Column(String(500), server_default=text("''"), comment='图片')
    createtime = Column(BIGINT(16), index=True, comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('normal', 'hidden', 'rejected'), server_default=text("'normal'"), comment='状态')


class FaCmsModel(Base):
    __tablename__ = 'fa_cms_model'
    __table_args__ = {'comment': '内容模型表'}

    id = Column(SMALLINT(5), primary_key=True)
    name = Column(CHAR(30), server_default=text("''"), comment='模型名称')
    table = Column(CHAR(20), server_default=text("''"), comment='表名')
    fields = Column(Text, comment='字段列表')
    channeltpl = Column(String(100), server_default=text("''"), comment='栏目页模板')
    listtpl = Column(String(100), server_default=text("''"), comment='列表页模板')
    showtpl = Column(String(100), server_default=text("''"), comment='详情页模板')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    setting = Column(Text, comment='模型配置')


class FaCmsNavigation(Base):
    __tablename__ = 'fa_cms_navigation'
    __table_args__ = {'comment': '热门导航'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    user_id = Column(INTEGER(10), index=True, comment='会员ID')
    title = Column(String(255), server_default=text("''"), comment='标题')
    image = Column(String(255), server_default=text("''"), comment='图片')
    website = Column(String(255), server_default=text("''"), comment='导航链接')
    createtime = Column(BIGINT(16), index=True, comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    memo = Column(String(1500), server_default=text("''"), comment='备注')
    status = Column(Enum('normal', 'hidden', 'rejected'), server_default=text("'hidden'"), comment='状态')
    intro = Column(String(255), server_default=text("''"), comment='介绍')


class FaCmsOrder(Base):
    __tablename__ = 'fa_cms_order'
    __table_args__ = {'comment': '订单表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    orderid = Column(String(50), index=True, server_default=text("''"), comment='订单ID')
    user_id = Column(INTEGER(10), server_default=text("'0'"), comment='会员ID')
    archives_id = Column(INTEGER(10), index=True, server_default=text("'0'"), comment='文档ID')
    title = Column(String(100), comment='订单标题')
    amount = Column(DECIMAL(10, 2), server_default=text("'0.00'"), comment='订单金额')
    payamount = Column(DECIMAL(10, 2), server_default=text("'0.00'"), comment='支付金额')
    paytype = Column(String(50), comment='支付类型')
    paytime = Column(BIGINT(16), comment='支付时间')
    method = Column(String(100), server_default=text("''"), comment='支付方法')
    ip = Column(String(50), comment='IP地址')
    useragent = Column(String(255), comment='UserAgent')
    memo = Column(String(255), comment='备注')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('created', 'paid', 'expired'), server_default=text("'created'"), comment='状态')


class FaCmsPage(Base):
    __tablename__ = 'fa_cms_page'
    __table_args__ = {'comment': '单页表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    category_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='分类ID')
    admin_id = Column(INTEGER(10), server_default=text("'0'"), comment='管理员ID')
    type = Column(String(50), index=True, server_default=text("''"), comment='类型')
    title = Column(String(50), server_default=text("''"), comment='标题')
    seotitle = Column(String(255), server_default=text("''"), comment='SEO标题')
    keywords = Column(String(255), server_default=text("''"), comment='关键字')
    description = Column(String(255), server_default=text("''"), comment='描述')
    flag = Column(String(100), server_default=text("''"), comment='标志')
    image = Column(String(255), server_default=text("''"), comment='头像')
    content = Column(LONGTEXT, comment='内容')
    icon = Column(String(50), server_default=text("''"), comment='图标')
    views = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='点击')
    likes = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='点赞')
    dislikes = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='点踩')
    comments = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='评论')
    diyname = Column(String(100), index=True, server_default=text("''"), comment='自定义')
    showtpl = Column(String(50), server_default=text("''"), comment='视图模板')
    iscomment = Column(TINYINT(1), server_default=text("'1'"), comment='是否允许评论')
    parsetpl = Column(TINYINT(1), server_default=text("'0'"), comment='解析模板标签')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    deletetime = Column(BIGINT(16), comment='删除时间')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    status = Column(String(30), server_default=text("''"), comment='状态')


class FaCmsSearchLog(Base):
    __tablename__ = 'fa_cms_search_log'
    __table_args__ = {'comment': '搜索记录表'}

    id = Column(INTEGER(10), primary_key=True)
    keywords = Column(String(100), unique=True, server_default=text("''"), comment='关键字')
    nums = Column(INTEGER(10), server_default=text("'0'"), comment='搜索次数')
    createtime = Column(BIGINT(16), comment='搜索时间')
    status = Column(String(50), server_default=text("'hidden'"), comment='状态')


class FaCmsSpecial(Base):
    __tablename__ = 'fa_cms_special'
    __table_args__ = {'comment': '专题表'}

    id = Column(INTEGER(10), primary_key=True)
    admin_id = Column(INTEGER(10), server_default=text("'0'"), comment='管理员ID')
    title = Column(String(100), server_default=text("''"), comment='标题')
    tag_ids = Column(String(1500), server_default=text("''"), comment='标签ID集合')
    flag = Column(String(100), server_default=text("''"), comment='标志')
    label = Column(String(50), server_default=text("''"), comment='标签')
    image = Column(String(255), server_default=text("''"), comment='图片')
    banner = Column(String(255), server_default=text("''"), comment='Banner图片')
    diyname = Column(String(100), index=True, server_default=text("''"), comment='自定义名称')
    seotitle = Column(String(255), server_default=text("''"), comment='SEO标题')
    keywords = Column(String(100), comment='关键字')
    description = Column(String(255), comment='描述')
    intro = Column(String(255), comment='专题介绍')
    views = Column(INTEGER(10), server_default=text("'0'"), comment='浏览次数')
    comments = Column(INTEGER(10), server_default=text("'0'"), comment='评论次数')
    iscomment = Column(TINYINT(1), server_default=text("'1'"), comment='是否允许评论')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    deletetime = Column(BIGINT(16), comment='删除时间')
    template = Column(String(100), server_default=text("''"), comment='专题模板')
    status = Column(Enum('normal', 'hidden'), nullable=False, server_default=text("'normal'"), comment='状态')


class FaCmsSpiderLog(Base):
    __tablename__ = 'fa_cms_spider_log'
    __table_args__ = (
        Index('type', 'type', 'aid'),
        {'comment': '搜索引擎来访记录'}
    )

    id = Column(INTEGER(10), primary_key=True)
    type = Column(Enum('index', 'archives', 'page', 'special', 'channel', 'diyform', 'tag', 'user'), comment='类型')
    aid = Column(INTEGER(10), server_default=text("'0'"), comment='关联ID')
    name = Column(String(50), server_default=text("''"), comment='名称')
    url = Column(String(255), server_default=text("''"), comment='来访页面')
    nums = Column(INTEGER(10), server_default=text("'0'"), comment='来访次数')
    firsttime = Column(BIGINT(16), comment='首次来访时间')
    lastdata = Column(String(100), server_default=text("''"), comment='最后5次来访时间')
    lasttime = Column(BIGINT(16), comment='最后来访时间')


class FaCmsTag(Base):
    __tablename__ = 'fa_cms_tag'
    __table_args__ = {'comment': '标签表'}

    id = Column(INTEGER(10), primary_key=True)
    name = Column(String(50), unique=True, server_default=text("''"), comment='标签名称')
    nums = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='文档数量')
    seotitle = Column(String(100), server_default=text("''"), comment='SEO标题')
    keywords = Column(String(255), comment='关键字')
    description = Column(String(255), comment='描述')
    views = Column(INTEGER(10), comment='浏览次数')
    autolink = Column(TINYINT(1), server_default=text("'0'"), comment='自动内链')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('normal', 'hidden'), server_default=text("'normal'"), comment='状态')


class FaCmsTaggable(Base):
    __tablename__ = 'fa_cms_taggable'
    __table_args__ = {'comment': '标签列表'}

    id = Column(INTEGER(10), primary_key=True)
    tag_id = Column(INTEGER(10), index=True, comment='标签ID')
    archives_id = Column(INTEGER(10), index=True, comment='文档ID')
    createtime = Column(BIGINT(16), comment='添加时间')


class FaCommand(Base):
    __tablename__ = 'fa_command'
    __table_args__ = {'comment': '在线命令表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    type = Column(String(30), nullable=False, server_default=text("''"), comment='类型')
    params = Column(String(1500), nullable=False, server_default=text("''"), comment='参数')
    command = Column(String(1500), nullable=False, server_default=text("''"), comment='命令')
    content = Column(Text, comment='返回结果')
    executetime = Column(BIGINT(16), comment='执行时间')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('successed', 'failured'), nullable=False, server_default=text("'failured'"), comment='状态')


class FaConfig(Base):
    __tablename__ = 'fa_config'
    __table_args__ = {'comment': '系统配置'}

    id = Column(INTEGER(10), primary_key=True)
    name = Column(String(30), unique=True, server_default=text("''"), comment='变量名')
    group = Column(String(30), server_default=text("''"), comment='分组')
    title = Column(String(100), server_default=text("''"), comment='变量标题')
    tip = Column(String(100), server_default=text("''"), comment='变量描述')
    type = Column(String(30), server_default=text("''"), comment='类型:string,text,int,bool,array,datetime,date,file')
    visible = Column(String(255), server_default=text("''"), comment='可见条件')
    value = Column(Text, comment='变量值')
    content = Column(Text, comment='变量字典数据')
    rule = Column(String(100), server_default=text("''"), comment='验证规则')
    extend = Column(String(255), server_default=text("''"), comment='扩展属性')
    setting = Column(String(255), server_default=text("''"), comment='配置')


class FaEm(Base):
    __tablename__ = 'fa_ems'
    __table_args__ = {'comment': '邮箱验证码表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    event = Column(String(30), server_default=text("''"), comment='事件')
    email = Column(String(100), server_default=text("''"), comment='邮箱')
    code = Column(String(10), server_default=text("''"), comment='验证码')
    times = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='验证次数')
    ip = Column(String(30), server_default=text("''"), comment='IP')
    createtime = Column(BIGINT(16), comment='创建时间')


class FaSm(Base):
    __tablename__ = 'fa_sms'
    __table_args__ = {'comment': '短信验证码表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    event = Column(String(30), server_default=text("''"), comment='事件')
    mobile = Column(String(20), server_default=text("''"), comment='手机号')
    code = Column(String(10), server_default=text("''"), comment='验证码')
    times = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='验证次数')
    ip = Column(String(30), server_default=text("''"), comment='IP')
    createtime = Column(BIGINT(16), server_default=text("'0'"), comment='创建时间')


class FaTest(Base):
    __tablename__ = 'fa_test'
    __table_args__ = {'comment': '测试表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    user_id = Column(INTEGER(10), server_default=text("'0'"), comment='会员ID')
    admin_id = Column(INTEGER(10), server_default=text("'0'"), comment='管理员ID')
    category_id = Column(INTEGER(10), server_default=text("'0'"), comment='分类ID(单选)')
    category_ids = Column(String(100), comment='分类ID(多选)')
    tags = Column(String(255), server_default=text("''"), comment='标签')
    week = Column(Enum('monday', 'tuesday', 'wednesday'), comment='星期(单选):monday=星期一,tuesday=星期二,wednesday=星期三')
    flag = Column(SET('hot', 'index', 'recommend'), server_default=text("''"), comment='标志(多选):hot=热门,index=首页,recommend=推荐')
    genderdata = Column(Enum('male', 'female'), server_default=text("'male'"), comment='性别(单选):male=男,female=女')
    hobbydata = Column(SET('music', 'reading', 'swimming'), comment='爱好(多选):music=音乐,reading=读书,swimming=游泳')
    title = Column(String(100), server_default=text("''"), comment='标题')
    content = Column(Text, comment='内容')
    image = Column(String(100), server_default=text("''"), comment='图片')
    images = Column(String(1500), server_default=text("''"), comment='图片组')
    attachfile = Column(String(100), server_default=text("''"), comment='附件')
    keywords = Column(String(255), server_default=text("''"), comment='关键字')
    description = Column(String(255), server_default=text("''"), comment='描述')
    city = Column(String(100), server_default=text("''"), comment='省市')
    array = Column(String(255), server_default=text("''"), comment='数组:value=值')
    json = Column(String(255), server_default=text("''"), comment='配置:key=名称,value=值')
    multiplejson = Column(String(1500), server_default=text("''"), comment='二维数组:title=标题,intro=介绍,author=作者,age=年龄')
    price = Column(DECIMAL(10, 2), server_default=text("'0.00'"), comment='价格')
    views = Column(INTEGER(10), server_default=text("'0'"), comment='点击')
    workrange = Column(String(100), server_default=text("''"), comment='时间区间')
    startdate = Column(Date, comment='开始日期')
    activitytime = Column(DateTime, comment='活动时间(datetime)')
    year = Column(YEAR(4), comment='年')
    times = Column(Time, comment='时间')
    refreshtime = Column(BIGINT(16), comment='刷新时间')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    deletetime = Column(BIGINT(16), comment='删除时间')
    weigh = Column(INTEGER(10), server_default=text("'0'"), comment='权重')
    switch = Column(TINYINT(1), server_default=text("'0'"), comment='开关')
    status = Column(Enum('normal', 'hidden'), server_default=text("'normal'"), comment='状态')
    state = Column(Enum('0', '1', '2'), server_default=text("'1'"), comment='状态值:0=禁用,1=正常,2=推荐')


class FaThird(Base):
    __tablename__ = 'fa_third'
    __table_args__ = (
        Index('user_id', 'user_id', 'platform'),
        Index('platform', 'platform', 'openid', unique=True),
        Index('unionid', 'platform', 'unionid'),
        {'comment': '第三方登录表'}
    )

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    user_id = Column(INTEGER(10), server_default=text("'0'"), comment='会员ID')
    platform = Column(String(30), server_default=text("''"), comment='第三方应用')
    apptype = Column(String(50), server_default=text("''"), comment='应用类型')
    unionid = Column(String(100), server_default=text("''"), comment='第三方UNIONID')
    openname = Column(String(100), nullable=False, server_default=text("''"), comment='第三方会员昵称')
    openid = Column(String(100), server_default=text("''"), comment='第三方OPENID')
    access_token = Column(String(255), server_default=text("''"), comment='AccessToken')
    refresh_token = Column(String(255), server_default=text("'RefreshToken'"))
    expires_in = Column(INTEGER(10), server_default=text("'0'"), comment='有效期')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    logintime = Column(BIGINT(16), comment='登录时间')
    expiretime = Column(BIGINT(16), comment='过期时间')


class FaUser(Base):
    __tablename__ = 'fa_user'
    __table_args__ = {'comment': '会员表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    group_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='组别ID')
    username = Column(String(32), index=True, server_default=text("''"), comment='用户名')
    nickname = Column(String(50), server_default=text("''"), comment='昵称')
    password = Column(String(32), server_default=text("''"), comment='密码')
    salt = Column(String(30), server_default=text("''"), comment='密码盐')
    email = Column(String(100), index=True, server_default=text("''"), comment='电子邮箱')
    mobile = Column(String(11), index=True, server_default=text("''"), comment='手机号')
    avatar = Column(String(255), server_default=text("''"), comment='头像')
    level = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='等级')
    gender = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='性别')
    birthday = Column(Date, comment='生日')
    bio = Column(String(100), server_default=text("''"), comment='格言')
    money = Column(DECIMAL(10, 2), nullable=False, server_default=text("'0.00'"), comment='余额')
    score = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='积分')
    successions = Column(INTEGER(10), nullable=False, server_default=text("'1'"), comment='连续登录天数')
    maxsuccessions = Column(INTEGER(10), nullable=False, server_default=text("'1'"), comment='最大连续登录天数')
    prevtime = Column(BIGINT(16), comment='上次登录时间')
    logintime = Column(BIGINT(16), comment='登录时间')
    loginip = Column(String(50), server_default=text("''"), comment='登录IP')
    loginfailure = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='失败次数')
    joinip = Column(String(50), server_default=text("''"), comment='加入IP')
    jointime = Column(BIGINT(16), comment='加入时间')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    token = Column(String(50), server_default=text("''"), comment='Token')
    status = Column(String(30), server_default=text("''"), comment='状态')
    verification = Column(String(255), server_default=text("''"), comment='验证')


class FaUserGroup(Base):
    __tablename__ = 'fa_user_group'
    __table_args__ = {'comment': '会员组表'}

    id = Column(INTEGER(10), primary_key=True)
    name = Column(String(50), server_default=text("''"), comment='组名')
    rules = Column(Text, comment='权限节点')
    createtime = Column(BIGINT(16), comment='添加时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('normal', 'hidden'), comment='状态')


class FaUserMoneyLog(Base):
    __tablename__ = 'fa_user_money_log'
    __table_args__ = {'comment': '会员余额变动表'}

    id = Column(INTEGER(10), primary_key=True)
    user_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='会员ID')
    money = Column(DECIMAL(10, 2), nullable=False, server_default=text("'0.00'"), comment='变更余额')
    before = Column(DECIMAL(10, 2), nullable=False, server_default=text("'0.00'"), comment='变更前余额')
    after = Column(DECIMAL(10, 2), nullable=False, server_default=text("'0.00'"), comment='变更后余额')
    memo = Column(String(255), server_default=text("''"), comment='备注')
    createtime = Column(BIGINT(16), comment='创建时间')


class FaUserRule(Base):
    __tablename__ = 'fa_user_rule'
    __table_args__ = {'comment': '会员规则表'}

    id = Column(INTEGER(10), primary_key=True)
    pid = Column(INTEGER(10), comment='父ID')
    name = Column(String(50), comment='名称')
    title = Column(String(50), server_default=text("''"), comment='标题')
    remark = Column(String(100), comment='备注')
    ismenu = Column(TINYINT(1), comment='是否菜单')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    weigh = Column(INTEGER(10), server_default=text("'0'"), comment='权重')
    status = Column(Enum('normal', 'hidden'), comment='状态')


class FaUserScoreLog(Base):
    __tablename__ = 'fa_user_score_log'
    __table_args__ = {'comment': '会员积分变动表'}

    id = Column(INTEGER(10), primary_key=True)
    user_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='会员ID')
    score = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='变更积分')
    before = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='变更前积分')
    after = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='变更后积分')
    memo = Column(String(255), server_default=text("''"), comment='备注')
    createtime = Column(BIGINT(16), comment='创建时间')


class FaUserToken(Base):
    __tablename__ = 'fa_user_token'
    __table_args__ = {'comment': '会员Token表'}

    token = Column(String(50), primary_key=True, comment='Token')
    user_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='会员ID')
    createtime = Column(BIGINT(16), comment='创建时间')
    expiretime = Column(BIGINT(16), comment='过期时间')


class FaVersion(Base):
    __tablename__ = 'fa_version'
    __table_args__ = {'comment': '版本表'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    oldversion = Column(String(30), server_default=text("''"), comment='旧版本号')
    newversion = Column(String(30), server_default=text("''"), comment='新版本号')
    packagesize = Column(String(30), server_default=text("''"), comment='包大小')
    content = Column(String(500), server_default=text("''"), comment='升级内容')
    downloadurl = Column(String(255), server_default=text("''"), comment='下载地址')
    enforce = Column(TINYINT(1), nullable=False, server_default=text("'0'"), comment='强制更新')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    status = Column(String(30), server_default=text("''"), comment='状态')


class KaotikuCard(Base):
    __tablename__ = 'kaotiku_card'
    __table_args__ = {'comment': '答题卡（阅卷）'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态 1.开始答题2.手动交卷3.超时未交卷,4.超时自动交卷,  5已自动阅卷  6已完成阅卷7.发布成绩')
    paper_id = Column(INTEGER(11), comment='考卷ID')
    room_id = Column(INTEGER(11), comment='考场ID')
    user_id = Column(INTEGER(11), comment='用户ID')
    point = Column(Float, nullable=False, comment='得分')
    adjudge_user_id = Column(INTEGER(11), comment='判卷人ID')
    adjudge_time = Column(BIGINT(16), comment='判卷人姓名')
    start_time = Column(BIGINT(16), comment='答题开始时间')
    end_time = Column(BIGINT(16), comment='答题交卷时间')
    complete_num = Column(INTEGER(11), comment='题完成数量')
    all_num = Column(INTEGER(11), comment='题总数量')
    submit_time = Column(BIGINT(16), comment='提交时间')
    overtime = Column(SMALLINT(2), comment='交卷状态 1 主动交卷 2 超时收卷 3 强制收卷')


class KaotikuCardAnswer(Base):
    __tablename__ = 'kaotiku_card_answer'
    __table_args__ = {'comment': '答题卡试题用户答案'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态 1.开始答题2.手动交卷3.超时未交卷,4.超时自动交卷,  5已自动阅卷  6已完成阅卷7.发布成绩')
    card_id = Column(INTEGER(11), nullable=False, comment='答题卡ID')
    answer_id = Column(INTEGER(11), nullable=False, comment='答案ID')
    user_id = Column(INTEGER(11), nullable=False, comment='用户ID')
    valstr = Column(Text, nullable=False, comment='答案值')


class KaotikuExamPop(Base):
    __tablename__ = 'kaotiku_exam_pop'
    __table_args__ = {'comment': '考卷授权'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    type_id = Column(INTEGER(11), nullable=False, comment='考卷分类ID')
    user_id = Column(INTEGER(11), nullable=False, comment='所有者ID')
    username = Column(VARCHAR(64), nullable=False, server_default=text("''"), comment='所有者名称')
    fun_type = Column(SMALLINT(2), nullable=False, comment='权限类型，1使用权、2维护权')


class KaotikuExamStat(Base):
    __tablename__ = 'kaotiku_exam_stat'
    __table_args__ = {'comment': '用户答题统计'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')
    subject_num = Column(INTEGER(11), server_default=text("'0'"), comment='累计答题')
    error_sub_num = Column(INTEGER(11), comment='累计错题')
    paper_num = Column(INTEGER(11), comment='累计答卷')
    test_num = Column(INTEGER(11), comment='累计练习卷')


class KaotikuExamType(Base):
    __tablename__ = 'kaotiku_exam_type'
    __table_args__ = {'comment': '考试业务分类'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    parent_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='父ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')


class KaotikuMaterial(Base):
    __tablename__ = 'kaotiku_material'
    __table_args__ = {'comment': '试题材料'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    title = Column(String(512), comment='资料标题')
    text = Column(Text, comment='资料正文')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=sqlalchemy.text("'1'"), comment='状态')
    p_content = Column(String(128), comment='备注')


class KaotikuPaper(Base):
    __tablename__ = 'kaotiku_paper'
    __table_args__ = {'comment': '答卷'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    parent_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='父ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='试卷简介')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'100'"), comment='权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态,1新建，0停用，2发布')
    exam_type_id = Column(INTEGER(11), comment='考试分类ID')
    subject_num = Column(INTEGER(11), server_default=text("'0'"), comment='题目数量')
    point_num = Column(INTEGER(11), server_default=text("'0'"), comment='总分')
    complete = Column(INTEGER(11), server_default=text("'0'"), comment='完成人数')
    book_num = Column(INTEGER(11), server_default=text("'0'"), comment='收藏数量')
    avg_point = Column(INTEGER(11), server_default=text("'0'"), comment='平均得分')
    top_point = Column(INTEGER(11), server_default=text("'0'"), comment='最高得分')
    low_point = Column(INTEGER(11), server_default=text("'0'"), comment='最低得分')
    advice_time = Column(INTEGER(11), comment='建议完成时长')
    paper_note = Column(Text, comment='试卷说明')
    pass_score = Column(SMALLINT(5), server_default=text("'0'"), comment='及格分数')
    start_time = Column(BIGINT(16), comment='使用开始时间')
    end_time = Column(BIGINT(16), comment='使用结束时间')


class KaotikuPaperChapter(Base):
    __tablename__ = 'kaotiku_paper_chapter'
    __table_args__ = {'comment': '试卷章节'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    stype = Column(String(16), nullable=False, comment='出题类型 1.手动出题，2随机出题')
    ptype = Column(SMALLINT(2), nullable=False, comment='章节类型 1.结构，2内容')
    initpoint = Column(INTEGER(11), comment='章节初始得分')
    name = Column(String(64), comment='章节名称')
    subject_type_ids = Column(String(32), comment='题库分类')
    subject_num = Column(INTEGER(11), comment='题目数量')
    subject_point = Column(INTEGER(11), comment='题目得分')
    text_note = Column(Text, comment='章节描述')
    parent_id = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='上级章节')
    paper_id = Column(INTEGER(11), nullable=False, comment='试卷id')
    p_content = Column(String(128), comment='备注')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')
    tip_type = Column(String(64), comment='题类型')
    level = Column(String(32), server_default=text("'3'"), comment='难度')


class KaotikuPaperGenerate(Base):
    __tablename__ = 'kaotiku_paper_generate'
    __table_args__ = {'comment': '在线命令表'}

    id = Column(INTEGER(10), primary_key=True, comment='ID')
    type = Column(String(30), nullable=False, server_default=text("''"), comment='类型')
    params = Column(String(1500), nullable=False, server_default=text("''"), comment='参数')
    content = Column(Text, comment='返回结果')
    executetime = Column(BIGINT(16), comment='执行时间')
    createtime = Column(BIGINT(16), comment='创建时间')
    updatetime = Column(BIGINT(16), comment='更新时间')
    status = Column(Enum('successed', 'failured'), nullable=False, server_default=text("'failured'"), comment='状态')
    paper_id = Column(INTEGER(11), comment='考卷ID')


class KaotikuPaperSubject(Base):
    __tablename__ = 'kaotiku_paper_subject'
    __table_args__ = {'comment': '考卷试题'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'100'"), comment='权重')
    subject_id = Column(INTEGER(11), server_default=text("'0'"), comment='题目ID')
    paper_id = Column(INTEGER(11), comment='考卷ID')
    chapter_id = Column(INTEGER(11), comment='考卷章节ID')
    point = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='得分')


class KaotikuPaperUserown(Base):
    __tablename__ = 'kaotiku_paper_userown'
    __table_args__ = {'comment': '用户答题成绩'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    paper_name = Column(String(128), nullable=False, comment='考卷名称')
    room_name = Column(String(128), comment='考场名称')
    score = Column(Float, comment='得分')
    rpcent = Column(INTEGER(11), comment='正确率')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')
    paper_id = Column(INTEGER(11), comment='考卷ID')
    room_id = Column(INTEGER(11), comment='考场ID')
    card_id = Column(INTEGER(11), comment='答题卡id')
    modeltype = Column(SMALLINT(2), server_default=text("'1'"), comment='类型 1.历史答卷,2:收藏')
    user_id = Column(INTEGER(11), comment='用户id')
    username = Column(String(64), nullable=False, comment='用户名称')


class KaotikuRoom(Base):
    __tablename__ = 'kaotiku_room'
    __table_args__ = {'comment': '考场'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    name = Column(String(64), nullable=False, comment='考场名称')
    start_time = Column(BIGINT(16), comment='使用开始时间')
    end_time = Column(BIGINT(16), comment='使用结束时间')
    room_type_id = Column(INTEGER(11), comment='考场分类ID')
    write_type = Column(SMALLINT(2), comment='答题类型 1指定人0任何人2.匿名答题')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态 1.可用，0.临时')
    time_len = Column(INTEGER(11), nullable=False, comment='答题时长')
    room_note = Column(Text, comment='考场说明')
    p_content = Column(String(128), comment='备注')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    signup_mode = Column(String(16), comment='报名方式')
    is_makeup = Column(SMALLINT(2), server_default=text("'0'"), comment='补考方式')
    makeup_count = Column(INTEGER(11), server_default=text("'1'"), comment='补考次数')
    pic = Column(String(255), comment='封面图片')


class KaotikuRoomPaper(Base):
    __tablename__ = 'kaotiku_room_paper'

    id = Column(INTEGER(11), primary_key=True)
    room_id = Column(INTEGER(11), nullable=False)
    paper_id = Column(INTEGER(11), nullable=False)
    name = Column(String(512))
    pass_point = Column(Float)


class KaotikuRoomPop(Base):
    __tablename__ = 'kaotiku_room_pop'
    __table_args__ = {'comment': '考卷授权'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    type_id = Column(INTEGER(11), nullable=False, comment='考场分类ID')
    user_id = Column(INTEGER(11), nullable=False, comment='所有者ID')
    username = Column(VARCHAR(64), nullable=False, server_default=text("''"), comment='所有者名称')
    fun_type = Column(SMALLINT(2), nullable=False, comment='权限类型，1使用权、2维护权')


class KaotikuRoomType(Base):
    __tablename__ = 'kaotiku_room_type'
    __table_args__ = {'comment': '考试业务分类'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    parent_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='父ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')


class KaotikuSubject(Base):
    __tablename__ = 'kaotiku_subject'
    __table_args__ = {'comment': '试题'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    analysis_num = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='解析数量')
    do_num = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='答题人次')
    right_num = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='正确回答人次')
    introduction = Column(String(512), comment='题目描述')
    praise_num = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='点赞数量')
    comment_num = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='评论数量')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态 1.可用，0.临时')
    type_id = Column(INTEGER(11), comment='试题分类ID')
    level = Column(String(32), server_default=text("'3'"), comment='难度')
    deletetime = Column(BIGINT(16), comment='删除时间')
    material_id = Column(INTEGER(11), comment='材料id')
    material_subject_id = Column(INTEGER(11), comment='材料试题id')


class KaotikuSubjectAnalysi(Base):
    __tablename__ = 'kaotiku_subject_analysis'
    __table_args__ = {'comment': '试题解析'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    subject_id = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='subject ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')


class KaotikuSubjectAnswer(Base):
    __tablename__ = 'kaotiku_subject_answer'
    __table_args__ = {'comment': '试题答案'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    version_id = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='父ID')
    p_content = Column(String(128), comment='备注')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='答案权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')
    answer = Column(String(512), nullable=False, comment='答案')
    answer_note = Column(Text, comment='答案描述')
    right_answer = Column(SMALLINT(2), nullable=False, server_default=text("'0'"), comment='正确答案')
    group_no = Column(INTEGER(11), comment='分组编号')
    score = Column(Float, comment='得分')


class KaotikuSubjectComment(Base):
    __tablename__ = 'kaotiku_subject_comment'
    __table_args__ = {'comment': '试题评论'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态 1.开始答题2.手动交卷3.超时未交卷,4.超时自动交卷,  5已自动阅卷  6已完成阅卷7.发布成绩')
    text = Column(Text, comment='评论内容')
    user_id = Column(INTEGER(11), comment='创建用户编号')
    username = Column(String(64), comment='创建用户名称')
    subject_id = Column(INTEGER(32), nullable=False, index=True, comment='试题ID')


class KaotikuSubjectPop(Base):
    __tablename__ = 'kaotiku_subject_pop'
    __table_args__ = (
        Index('type_id_user_id_fun_type_unique', 'type_id', 'user_id', 'fun_type', unique=True),
        {'comment': '题库权限'}
    )

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    type_id = Column(INTEGER(11), nullable=False, comment='题库分类ID')
    user_id = Column(INTEGER(11), nullable=False, comment='所有者ID')
    username = Column(String(64), nullable=False, server_default=text("''"), comment='所有者名称')
    fun_type = Column(SMALLINT(2), nullable=False, comment='权限类型，1使用权、2维护权')


class KaotikuSubjectType(Base):
    __tablename__ = 'kaotiku_subject_type'
    __table_args__ = {'comment': '题库分类'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    parent_id = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='父ID')
    name = Column(String(64), comment='名称')
    p_content = Column(String(128), comment='备注')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    create_time = Column(BIGINT(16), comment='创建时间')
    update_time = Column(BIGINT(16), comment='修改时间')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')
    read_pop = Column(SMALLINT(2), server_default=text("'1'"), comment='使用权,1所有人,2指定人')
    write_pop = Column(SMALLINT(2), server_default=text("'1'"), comment='维护权,1所有人,2指定人')


class KaotikuSubjectUserown(Base):
    __tablename__ = 'kaotiku_subject_userown'
    __table_args__ = {'comment': '用户题库'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    user_id = Column(INTEGER(11), server_default=text("'0'"), comment='用户ID')
    username = Column(String(64), nullable=False, comment='用户名称')
    create_time = Column(BIGINT(16), comment='创建时间')
    p_content = Column(String(128), comment='备注')
    modeltype = Column(SMALLINT(2), nullable=False, server_default=text("'1'"), comment='类型 1.历史答题,2:收藏,3:错题')
    subject_id = Column(INTEGER(11), server_default=text("'0'"), comment='题目ID')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态,1新建，0停用，2发布')
    card_id = Column(INTEGER(11), server_default=text("'0'"), comment='答题卡ID')


class KaotikuSubjectVersion(Base):
    __tablename__ = 'kaotiku_subject_version'
    __table_args__ = {'comment': '试题版本'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    tip_str = Column(String(1024), nullable=False, comment='题目')
    tip_note = Column(Text, comment='题目描述')
    tip_type = Column(String(32), nullable=False, comment='题目类型 1.填空，2.单选，3.多选，4判断，5问答,6附件')
    answered = Column(SMALLINT(2), server_default=text("'1'"), comment='答案状态 1设置正确答案，0未设置正确答案，3未知')
    subject_id = Column(INTEGER(11), comment='试题ID')
    p_content = Column(String(128), comment='备注')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')
    create_time = Column(BIGINT(16), comment='创建时间')
    score = Column(Float, comment='得分（材料子题）')
    short_answer = Column(String(1024), comment='简答标准答案')


class KaotikuRegion(Base):
    __tablename__ = 'kaotiku_region'
    __table_args__ = {'comment': '地区'}

    id = Column(INTEGER(11), primary_key=True, comment='ID')
    name = Column(String(100), nullable=False, comment='名称')
    pid = Column(INTEGER(11), comment='父编号')
    level = Column(String(32), comment='等级')
    weigh = Column(INTEGER(10), nullable=False, server_default=text("'0'"), comment='权重')
    status = Column(SMALLINT(2), server_default=text("'1'"), comment='状态')